let arr = [];
function add() {
    let num = prompt('请输入添加用户名的数量：');
    if (isNaN(num)) {
        return alert('请输入数字');
    }
    if (num < 0) {
        return alert('数量不能小于0！');
    }
    num = parseInt(num);
    for (let i = 0; i < num;) {
        let name = prompt(`请输入第${i + 1}个用户名：`);
        if (!name) {
            alert('用户名不能为空');
            continue;
        }
        //首尾去空格
        name = name.trim();
        arr.push(name);
        console.log(arr);
        i++;
    }
}
function show() {
    for (let i = 0; i < arr.length; i++) {
        let s = arr[i];
        document.write(s + '&nbsp;&nbsp');
    }
}
